﻿#region Using Statements
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
#endregion

namespace GameStateManagement
{
    public class CreditScreen: GameScreen
    {
        #region Fields

        ContentManager content;
        Texture2D backgroundTexture;
        private Rectangle fullscreen;
        private Vector2 position;
        private SpriteFont Font;

        #endregion

        #region Initialization


        
        
        
        public CreditScreen()
        {
            TransitionOnTime = TimeSpan.FromSeconds(.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);
        }


        
        
        
        
        
        
        
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height);
            position = new Vector2(viewport.X + 20, viewport.Y + viewport.Height - 30);

            Font = content.Load<SpriteFont>("Tip");
          
            backgroundTexture = content.Load<Texture2D>("zombie-hand");
        }


        public override void HandleInput(InputState input)
        {
            base.HandleInput(input);
            PlayerIndex playerIndex;
            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.Escape, null, out playerIndex))
            {
                this.ExitScreen();
            }
        }
        
        
        public override void UnloadContent()
        {
            content.Unload();
        }


        #endregion

        #region Update and Draw        
                
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
  
            spriteBatch.Begin();

            spriteBatch.Draw(backgroundTexture, fullscreen,
                             new Color(TransitionAlpha, TransitionAlpha, TransitionAlpha));
            spriteBatch.DrawString(Font, "Press ESC to back", position, Color.White);
            spriteBatch.End();
        }


        #endregion
    }
}
